home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 December / PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin / prgmming / dos / pascal1 / dialer.pas < prev    next >
Pascal/Delphi Source File  |  1989-10-18  |  4KB  |  114 lines

  1. (*
  2. This has been tested on a CASE 4624/V and a Robotics Courier 2400
  3.  
  4. THIS HAS NOT BEEN DEBUGGED and I am not great with communications.
  5. It is just that I had to search for days to find a simple way
  6. to make one of my programs dial out on a modem, and I have used Compu
  7. Serve so many times for other ideas but could find nothing for this.
  8. So I should share this with others.
  9.  
  10. After many days of searching the answer turned out to be really simple
  11. and this is it.
  12.  
  13.  
  14. This is a small procedure that will enable you to use your modem as a dialer
  15. it uses Intr 14h to set the modem parameters and the built in TP array Port
  16. to write the Hayes AT Command set to the com port.
  17.  
  18.  
  19. -----------------------------------------------------------------------------
  20. The bits of the AL register are as follows for serial initialization
  21.  
  22. 7,6,5               4,3            2              1,0
  23. Baud Rate           Parity         Stop Bits      Word Length
  24.  
  25. 000 = 110           00 = none      0 = 1 bit      10 = 7 bits
  26. 001 = 150           01 = odd       1 = 2 bits     11 = 8 bits
  27. 010 = 300           10 = none
  28. 011 = 600           11 = even
  29. 100 = 1200
  30. 101 = 2400
  31. 110 = 4800
  32. 111 = 9600
  33.  
  34. For 2400 Baud,  Even Parity, 1 Stop and 7 bits
  35.  
  36. you would load Binary 101 11 0 10 into the AL register
  37. and 10111010 equals BA in hex
  38.  
  39. -----------------------------------------------------------------------------
  40.  
  41. Port is a TP build in array for accessing the COM ports
  42.  
  43.   so   " Port[$3F8] := Ord('A'); "  sends the character 'A' to COM1
  44.   or   " Ch := Chr(Port[$3F8]);  "  reads a character from COM1
  45.  
  46. Addresses are
  47.  
  48.         3F8h = COM1
  49.         2F8h = COM2
  50.         3E8h = COM3
  51.         2E8h = COM4
  52.  
  53. -----------------------------------------------------------------------------
  54.  
  55. Calling Interupt $14 will access the Serial Port. The function depends
  56. on what is in the AH register
  57. { DX Holds The COM Port Number : 0 = COM1, 1 = COM2, 2 = COM3 and 3 = COM4 }
  58.  
  59.         AH = 0   Sets serial port parameters
  60.         AH = 1   Outputs Character to serial port
  61.         AH = 2   Inputs character from serial port
  62.         AH = 3   Returns Status information about a serial port
  63.  
  64.  
  65. I Just Use Function 0 to set up the Serial Port
  66.  
  67.  
  68. *)
  69.  
  70.  
  71. Program Dialer;
  72.  
  73. Uses Dos,Crt;
  74.  
  75. Var TestNumber : String;
  76.  
  77.  
  78. Procedure SendModemStr(ModemStr : String);
  79.  
  80.  
  81. var
  82.    I    : Integer;
  83.    Regs : Registers;
  84.  
  85. begin
  86.   regs.ah := 0;                      (*  Set Serial Port Parameters        *)
  87.   Regs.al := $BA;                    (*  Set To 8, 1, Even at 2400 Baud    *)
  88.   regs.dx := $0;                     (*  Set COM Port to COM1              *)
  89.   Intr($14,Regs);                    (*  Call Intr 14h to set these        *)
  90.   for i := 1 to Length(ModemStr) do
  91.   begin
  92.     Port[$3F8] := Ord(ModemStr[i]);  (*  Send Character to COM1            *)
  93.     Delay(5);                        (*  Delay Between Sends Because Speed *)
  94.   end;                               (*  of Computer is to Fast For Modem  *)
  95.  
  96.   Delay(3000);                       (*  Set so as not to miss key press   *)
  97.   writeln('Press any Key');
  98.   Repeat Until ReadKey <> '';        (*  Wait For Key Press                *)
  99.  
  100.   ModemStr := 'ATH' + #13;           (*  Set and Send Hang Up Command      *)
  101.   for i := 1 to Length(ModemStr) do
  102.   begin
  103.     Port[$3F8] := Ord(ModemStr[i]);  (*  Send Hang Up Command to Modem     *)
  104.     Delay(5);
  105.   end;
  106. end;
  107.  
  108.  
  109. begin
  110.   (* Set Up Your Dialer Program Here *)
  111.   TestNumber := '555 5555';
  112.   SendModemStr('ATDT'+TestNumber+#13);  (* Add AT Command ATDT which is Tone *)
  113.                                         (* Dial and <CR> to Number String    *)
  114. end.